package values.skill
{
	import core.manager.battle.BattleCountManager;
	import core.manager.battle.BattleEffectManager;

	/**
	 * 消耗自己的属性 并且对对方造成伤害的特殊技能 
	 * @author azhang
	 * 
	 */	
	public class HurtMeAdditinalEffectValue extends AdditionalEffectValue
	{
		public function HurtMeAdditinalEffectValue()
		{
			super();
		}
		
		public static const HURT_MP:String = "hurt_mp";
		
		override public function effect():void
		{
			var tempateV:AdditionalEffectTemplateValue = _skillValue.template.additional;
			//////////////////////////几率没达到///////////////////////////////
			if(!BattleCountManager.countRandom(_skillValue.getLevelValueByTag(tempateV.basePossiblity))) return;
			/////////////////////////被抵抗了/////////////////////////////////
			if(tempateV.canResist && !_skillValue.checkSkillHasLogic(LogicEffectValue.IGNORE_RESIST) && BattleCountManager.countRandom(BattleCountManager.countResistRate(_owner , _hitter))) return;
			
			var effectObj:Object = {};
			var num:Number;
			for each(var proV:AdditionalProTemplateValue in tempateV.proDic)
			{
				if(_hitter[proV.proName] != null)
				{
					if(!proV.isSpecial())
					{
						if(proV.needBaseNum)
						{
							num = _baseDamageNum * _skillValue.getLevelValueByTag(proV.baseNum) / 100;
							_hitter[proV.proName] -= num;
						}
						else
						{
							num = SkillNumTypeKey.getResult(proV.numType , _hitter[proV.proName] , _skillValue.getLevelValueByTag(proV.baseNum));
							_hitter[proV.proName] -= num;
						}
					}
					else
					{
						num = otherEffect(proV);
						_hitter[proV.proName] -= num;
					}
					
					BattleEffectManager.showEffectValue(_owner , _hitter , {num:num , proName:proV.proName});
				}
			}
		}
		
		
		protected function otherEffect(value:AdditionalProTemplateValue):Number
		{
			switch(value.special)
			{
				case HURT_MP:
					var effNum:Number = _baseDamageNum * _owner.mp * _skillValue.getLevelValueByTag(value.params.a) / 100;
					BattleEffectManager.showEffectValue(_owner , _owner , {num:_owner.mp , proName:"mp"});
					_owner.mp = 0;
					return effNum;
					break;
				default:
					return 0;
			}
		}
		
	}
}